﻿using HZU.ZP.Data.Impl;
using HZU.ZP.Data.Interfaces;
using HZU.ZP.Domain.IService;
using HZU.ZP.Domain.Model;
using HZU.ZP.Domain.ServiceImpl.Mappers;
using System;
using System.Collections.Generic;
using System.Text;

namespace HZU.ZP.Domain.ServiceImpl.PCSvc
{
    public class CommentService:ICommentService
    {
        private CommentMapper _mapper = new CommentMapper();
        private ICommentDao _sqlData;
        public CommentService(ICommentDao sqlData)
        {
            _sqlData = sqlData;
        }

        public bool Add(Comment comment)
        {
            var commentDao = _mapper.MapToDao(comment);
            _sqlData.Add(commentDao);
            return true;
        }

        public bool Delete(int id)
        {
            _sqlData.Delete(id);
            return true;
        }

        public IList<Comment> GetByCommentId(int commentId)
        {
            return _mapper.MapToDomainList(_sqlData.GetByCommentId(commentId));
        }

        public int GetByNoticeCount(int noticeId)
        {
            return _sqlData.GetByNoticeCount(noticeId);
        }

        public IList<Comment> GetByNoticeId(int noticeId, int pageIndex)
        {
            return _mapper.MapToDomainList(_sqlData.GetByNoticeId(noticeId, pageIndex));
        }
    }
}
